package com.ygqh.baby.controller.admin;

import com.ygqh.baby.ao.DataStatus;
import com.ygqh.baby.ao.Message;
import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ResultSet;
import com.ygqh.baby.po.YgSearchWords;
import com.ygqh.baby.service.YgSearchWordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @Author: sunshuo
 * @Date: 2019/3/11 18:08
 * @Version: 1.0
 */
@Controller
@RequestMapping("admin/searchwords")
public class SearchWordsController {

	@Autowired
	private YgSearchWordsService ygSearchWordsService;

	@RequestMapping("search")
	@ResponseBody
	public Map<String, Object> search(QueryInfo queryInfo, String words, Long minHot, DataStatus status) {
		ResultSet<YgSearchWords> resultSet = ygSearchWordsService.search(queryInfo, words, minHot, status);
		return resultSet.toDatatables(null);
	}

	@RequestMapping("updateWords")
	@ResponseBody
	public Message updateWords(YgSearchWords searchWords) {
		ygSearchWordsService.update(searchWords);
		return Message.success(null);
	}
}
